package org.apache.spark.common

import akka.actor.{Actor, ActorSelection, ActorSystem, Props}

/**
 * @author: chenzhidiao
 * @date: 2021/1/4 10:27
 * @description:
 * @version: 1.0
 */
object Message {

  //注册消息  client 注册到 server
  case class RegisterClient(clientid: String, hostname:String,port:Int,ClientActorSystemName:String,ClientActorName:String)

  //注册客户端消息，NettyRpc
  case class RegisterNettyClient(clientid: String, hostname:String,port:Int,ClientEndpointName:String)

  //注册完成消息 client 注册到 server 完成
  case class RegisteredClient(val serverHostname: String)

  //注册完成消息，NettyRpc
  case class RegisteredNettyClient(msg:String)

  //心跳消息 client 发送给 server 的心跳
  case class Heartbeat(val clientid: String)

  //通知所有客户端有客户端上线
  case class NotifyOnline(clientid:String)

  //通知所有客户端有客户端下线
  case class NotifyOffline(clientid:String)

  // 一个发送心跳的信号
  case object SendMessage

  // 一个检查信号
  case object CheckTimeOut

  //client 信息类
  class ClientInfo(val clientid: String, val clientHostname: String, val clientPort: Int, val clientActorSystemName:String,val clientActorName:String) {
    //上一次心跳时间
    var lastHeartBeatTime: Long = _

    override def toString: String = {
      "客户端编号："+clientid + ", 客户端主机名：" + clientHostname + ", 客户端端口：" + clientPort
    }
  }


  class NettyClientInfo(val clientid: String, val clientHostname: String, val clientPort: Int) {
    //上一次心跳时间
    var lastHeartBeatTime: Long = _

    override def toString: String = {
      "客户端编号："+clientid + ", 客户端主机名：" + clientHostname + ", 客户端端口：" + clientPort
    }
  }

}
